1. Adding DNS Zones
You can add DNS zones with dnscmd. The basic format is
dnscmd server /zoneadd zonename /zonetype
The following table shows valid zone types you can create with the /zoneadd command.
Valid Zone Types for /zoneadd | Comments |
---|
/dsprimary
dnscmd server /zoneadd zonename
/dsprimary
c:\>dnscmd dc1 /zoneadd
pcg.pearson.pub /dsprimary
| Adds
an ADI zone named pcg.pearson.pub. If the server has a pearson.pub
zone, this command adds the pcg zone in the pearson.pub zone (as
pcg.pearson.pub). |
/primary
dnscmd server /zoneadd zonename
/primary /file filename
c:\>dnscmd dc1 /zoneadd
learning.pearson.pub /primary
/file learning.dns
| You can create a nonADI primary DNS zone with the /primary switch. You must specify only the server, the zone name, and the name of the file to hold the DNS zone data. |
/secondary
dnscmd dc1 /zoneadd zonename
/secondary masterIPaddress
c:\>dnscmd dc1 /zoneadd
second.pearson.pub /secondary
192.168.1.150
| If you have a primary DNS server in your network, you can use the /secondary
switch to create a secondary zone. You must specify the server where
you’re creating the zone, the zone name, and the IP address of the
master or primary DNS server. |
Figure 1 shows the result of executing the commands in the previous table. Notice that each zone has been added as an additional zone.
Note
In the Figure 1,
the _msdcs.pearson.pub zone includes the SRV records for the domain,
and the pearson.pub zone is the primary ADI zone for the domain. Only
the other three zones were created from the previous table.
You can delete the zones created in the previous table with the following commands:
dnscmd dc1 /zonedelete pcg.pearson.pub /f /dsdel
dnscmd dc1 /zonedelete learning.pearson.pub /f
dnscmd dc1 /zonedelete second.pearson.pub /f
Note
The /f switch
suppresses confirmation prompts, which is useful in a script. If the
zone is an ADI zone (such as pcg.pearson.pub), you need to include the /dsdel switch to delete it from Active Directory.
2. Creating and Deleting DNS Records
It’s also possible to create and delete records in a DNS zone. The following table shows how this is done.
Commands to Create and Delete DNS Records | Comments |
---|
Create DNS records.
/recordadd
dnscmd /recordadd zonename hostname
recordtype IPaddress
c:\>dnscmd /recordadd pearson.pub Web2
A 192.168.1.11
c:\>dnscmd /recordadd pearson.pub Web2
ptr 192.168.1.11
| You can add different types of records with the /recordadd switch.
The example commands add an A record and a ptr record to the pearson.pub zone. |
Delete DNS records.
/recorddelete
dnscmd dnsserver /recorddelete zonename
hostname record type /f
c:\>dnscmd dc1 /recorddelete
pearson.pub web2 a /f
c:\>dnscmd dc1 /recorddelete
pearson.pub web2 ptr /f
| DNS records can be deleted with the /recorddelete switch. You must specify the server hosting the zone, the name of the zone, the name of the host, and the record type (such as A or ptr).
Note
The /f switch suppresses the confirmation.
|